package jmetal.util.comparators;

import hidra.jmetal.core.Solution;
import java.util.Comparator;

public class DiversityFactorComparator implements Comparator {

	@Override
	public int compare(Object ob1, Object ob2) {
		if (ob1 == null) {
			return 1;
		} else if (ob2 == null) {
			return -1;
		}

		double dFactor1 = ((Solution) ob1).getDiversityFactor();
		double dFactor2 = ((Solution) ob2).getDiversityFactor();

		if (dFactor1 > dFactor2) {
			return -1;
		} else if (dFactor1 < dFactor2) {
			return 1;
		} else { 
			return 0;
		}
	}

}
